<% content_for(:page_title) do %>
  <%= Spree.t(:properties) %>
<% end %>

<% content_for(:page_alerts) do %>
  <div class="alert alert-info">
    Properties allow you to enrich your Product information.
  </div>
<% end %>

<% content_for :page_actions do %>
  <%= button_link_to Spree.t(:new_property), new_object_url, { class: "btn-primary", icon: 'plus', } %>
<% end if can?(:create, Spree::Property) %>

<% content_for :table_filter do %>
  <div>
    <%= search_form_for [:admin, @search] do |f| %>

      <%- locals = {f: f} %>

      <div class="row">
        <div class="col-12 col-lg-6">
          <div class="form-group">
            <%= f.label :name_or_presentation_cont, Spree.t(:name) %>
            <%= f.text_field :name_or_presentation_cont, class: "form-control js-quick-search-target js-filterable" %>
          </div>
        </div>
      </div>

      <div class="form-actions">
        <%= button Spree.t(:search), 'search' %>
      </div>

    <% end %>
    </div>
<% end if Spree::Property.any? %>

<% if @properties.present? %>
  <div class="table-responsive">
    <table class="table" id='listing_properties'>
      <thead class="text-muted">
      <tr>
        <th class="no-border handel-head"></th>
        <th><%= Spree.t(:internal_name) %></th>
        <th><%= Spree.t(:presentation) %></th>
        <th><%= Spree.t(:kind) %></th>
        <th><%= Spree.t(:products) %></th>
        <th><%= Spree.t(:visibility) %></th>
        <th class="actions"></th>
      </tr>
      </thead>
      <tbody data-controller="sortable" data-sortable-handle-value=".move-handle" data-sortable-resource-name-value="property" data-sortable-response-kind-value="turbo-stream">
        <%= render partial: 'spree/admin/properties/property', collection: @collection, cached: spree_base_cache_scope %>
      </tbody>
    </table>
    <%= render 'spree/admin/shared/index_table_options', collection: @collection, simple: true %>
  </div>
<% else %>
  <%= render 'spree/admin/shared/no_resource_found' %>
<% end %>
